package com.guigu.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GateWayConfig {

    /**
     * 硬编码配置路由规则
     *
     * @param builder RouteLocatorBuilder
     * @return
     */
    @Bean
    public RouteLocator myRouteLocator(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("baidunew",
                r -> r.path("guonei")
                        .uri("https://news.baidu.com/guonei"));
        return routes.build();
    }
}
